package iserver

import (
	"src/zeus/msgdef"
)

// ISrvNet 服务器的网状结构
type ISrvNet interface {
	GetSrvType() ServerType2
	GetSrvID() uint64
	GetSrvAddr() string

	PostMsgToSrv(srvID uint64, msg msgdef.IMsg) error
	// 发消息给客户端
	PostClient(eid uint64, srvID uint64, msg msgdef.IMsg) error
	// 发消息给客户端 (根据PID)
	PostClientByPID(pid uint64, msg msgdef.IMsg) error
	PostMsgToSpace(srvID uint64, spaceID uint64, msg msgdef.IMsg) error
	PostMsgToSrvByType(srvType ServerType2, group string, msg msgdef.IMsg) error
	IsSessExist(srvID uint64) bool

	// GetSrvInfo(srvID uint64) *ServerInfo
	GetCurSrvInfo() *ServerInfo
	GetSrvIDBySrvType(srvType ServerType2) (uint64, error) // (负载均衡获取) 一个服务器ID
	// 发消息给本地服务器指定类型,一般使用这个消息就是随边哪个服务器都可以,或是目标服务器就只有一个节点
	PostMsgTolocalSrvByType(srvType ServerType2, msg msgdef.IMsg) error
	//是否会连接此分组的服务器类型
	IsCanConnectBySrvType(group uint32, srvType ServerType2) (ok bool)

	// 遍历所有被动连接，返回false就退出遍历
	RangeSess(f func(sess ISess) bool)
	// 监听服务,服务发现变化,就会触发回调
	WatchServer()
}
